package cn.com.kblog.intercepor;


import javax.servlet.http.HttpServletRequest;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.kit.StringKit;


/**
 * 配置basepath 这里命名不准确 应该是域名
 * @author KK.Luo
 * Email luokai8@vip.qq.com
 * @date 2013-12-3下午5:36:36
 */
public class ContextInterceptor implements Interceptor {
    private String basepath = "basepath";

    public ContextInterceptor() {
    }

    public ContextInterceptor(String base) {
	if (StringKit.isBlank(base)) {
	    throw new IllegalArgumentException(
		    "contextPathKey can not be blank.");
	}
	this.basepath = base;
    }

   

    public void intercept(ActionInvocation ai) {
		ai.invoke();
		HttpServletRequest request = ai.getController().getRequest();
		request.setAttribute("basepath", basepath);
    }

}